package com.aaa.controller;

import com.aaa.service.impl.L_dataqueryServiceImpl;
import com.aaa.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/dataCX")
public class L_dataCX {

    @Autowired
    private L_dataqueryServiceImpl service;

    //文件上传下载路径
    @Value("${upload.path}")
    private String filePath; // D:/images/

    private String title;

    //右侧首页界面
    @RequestMapping("/main")
    public String shouyeString(){
        return  "Declarationmanagement/rightmain_CX";
    }

        @RequestMapping("/yemian")
        public String aaa() {
            service.panduan("CX");
            return "redirect:../dataquery/dataquery";
        }

        @RequestMapping("/rightmain")
        public String rightmain(String title){
            this.title=title;
            return  "Declarationmanagement/rightmainCX";
        }


        //资料查询
        @RequestMapping("/CX")
        @ResponseBody
        public Map CX(@RequestBody Map map){
            map.put("title",title);
            Map map1=new HashMap();
            map1.put("data",service.CX(map));
            map1.put("total",service.getCount(map));
            System.out.println(title);
            return  map1;
        }

        //资料下载
    @RequestMapping("/downLoad")
    public void downFile(String filePaths, HttpServletResponse response){
        FileUtil.downloadFile(filePath,filePaths,response);
    }

    //查询详情

    @RequestMapping("/cha{id}")
    @ResponseBody
    public  Map cha(Integer id){
        System.out.println(id);
        System.out.println(service.cha(id));
           return  service.cha(id);
    }
}
